﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="LinkList.ascx.cs" Inherits="admin_webparts_Plug_ins_HighlightLink_LinkList" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<%@ Import Namespace="NTTHAO.Web.BL.HighlightLink" %>
<%if (_Group != null)
  {
      string baseUrl = "?type=" + Request.QueryString["type"] + "&name=" + Request.QueryString["name"] + "&gid=" + Request.QueryString["id"]; %>
<div class="tip">
    <h1 style="left: 0px; position: relative;"><%=LanguageUtility.GetLanguageText("HLINK_GROUP_DETAIL", Session)%></h1>
    <div style="display: block; width: 32px; height: 32px; float: right; position: relative; top: -27px;"><a title="<%=LanguageUtility.GetLanguageText("CLICK_RETURN", Session) %>" href="?type=<%=Request.QueryString["type"] %>&name=<%=Request.QueryString["name"] %>"><img src="resources/images/Back.png" alt="" /></a></div>
</div>
<table cellspacing="0" cellpadding="3" border="1" class="grid" style="margin: 0px auto 10px;">
    <tr class="even">
        <td align="right" width="200px"><%=LanguageUtility.GetLanguageText("NAME", Session)%>:</td>
        <td><b><%=Server.HtmlEncode(this._Group.Name) %></b></td>
    </tr><%if (this._Group.ImageAvailable) { %>
    <tr class="odd">
        <td align="right">
            <%=LanguageUtility.GetLanguageText("DEFAULT_SIZE", Session)%>:
        </td>
        <td><%=(this._Group.DefaultWidth < 1) ? "*" : this._Group.DefaultWidth.ToString("0")%> x <%=(this._Group.DefaultHeight < 1) ? "*" : this._Group.DefaultHeight.ToString("0")%> pixels</td>
    </tr>
    <tr class="even">
        <td align="right">
            <%=LanguageUtility.GetLanguageText("AUTO_RESIZE", Session)%>:
        </td>
        <td><%=(this._Group.AutoResize ? ("<img src=\"resources/images/active_l.png\" />" + " (" + ((this._Group.ResizeWidth < 1) ? "*" : this._Group.ResizeWidth.ToString("0")) + " x " + ((this._Group.ResizeHeight < 1) ? "*" : this._Group.ResizeHeight.ToString("0")) + " pixels)") : "<img src=\"resources/images/inactive_l.png\" />")%></td>
    </tr><%} %>
    <tr class="odd">
        <td align="right"><%=LanguageUtility.GetLanguageText("HLINK_LIMIT", Session)%>:
        </td>
        <td><%=this._Group.MaxItemCount > 0 ? this._Group.MaxItemCount.ToString("0") : LanguageUtility.GetLanguageText("UNLIMITED", Session)%></td>
    </tr>
</table>
<div class="tip" style="overflow: hidden;">
	<div style="clear: left; float: left; overflow: hidden;"><h2 style="padding-top: 0px; line-height: 26px; margin-bottom:0px;"><%=LanguageUtility.GetLanguageText("HLINK_LIST", Session)%></h2></div>
	<div style="float: right; width: 450px; text-align: right;"><span id="addLink" class="yui-button yui-link-button yuibtn yuibtn-icon btnaddi"><span class="first-child"><a href="<%=baseUrl %>&action=addlink" tabindex="0"><%=LanguageUtility.GetLanguageText("ADD_NEW", Session)%></a></span></span></div>
<script type="text/javascript">
    YAHOO.util.Event.onContentReady('addLink', function () {
        var oAddCat = new YAHOO.widget.Button("addLink");
    });
</script>
</div>
<div style="border: solid 1px #89F;padding: 5px;margin-bottom: 10px;">
    <div style="overflow: hidden;font-weight: bold; padding-left: 2px;">
        <span><%=LanguageUtility.GetLanguageText("TOTAL") %>: <span style="color: #E76300;"><%=this._List == null ? 0 : this._List.Count %></span> <%=LanguageUtility.GetLanguageText("ITEMS") %>.</span> 
    </div>
</div>
<table border="1" cellpadding="0" cellspacing="0" class="grid" id="tbGrid" style="margin-top: 10px;">
    <tr>
        <th width="20px">#</th>
        <th><%=LanguageUtility.GetLanguageText("NAME", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("LINK", Session)%></th><%if (_Group.ImageAvailable) { %>
        <th><%=LanguageUtility.GetLanguageText("IMAGE", Session)%></th><%} %>
        <th class="desc"><span title="<%=LanguageUtility.GetLanguageText("ORDER_DESC", Session)%>"><%=LanguageUtility.GetLanguageText("ORDER", Session)%></span></th>
        <th><%=LanguageUtility.GetLanguageText("ACTIVE", Session)%></th>
        <th width="56px"><%=LanguageUtility.GetLanguageText("EDIT", Session)%></th>
    </tr>
<%
    if (this._List != null) 
    {
        string preImagePath = "/" + Constant.UPLOAD_FILE_PATH;
        for(int i = 0; i < _List.Count; i++) 
        {
            HighlightLink link = _List[i];
%>
    <tr>
        <td align="center"><%=((int)i + 1).ToString("0") %></td>
        <td align="left"><b><%=Server.HtmlEncode(link.Title) %></b></td>
        <td align="left"><a target="_blank" href="<%=link.Href %>"><%=Server.HtmlEncode(link.Href) %></a></td><%if (_Group.ImageAvailable) { %>
        <td align="center"><%if (link.ImageName.Length > 0) { %><a target="_blank" href="<%=preImagePath + this._Group.ImagePath + link.ImageName %>"><img src="ImageProvider.aspx?imgurl=<%=Server.UrlEncode(preImagePath + this._Group.ImagePath + link.ImageName)%>" alt="" style="max-width: 100px; max-height: 75px;" /></a><%} else { %>&nbsp;<%} %></td><%} %>
        <td align="center"><input type="text" id="txtOrder_<%=i.ToString("0") %>" value="<%=link.Order.ToString("0") %>" linkid="<%=link.ID.ToString("0") %>" order="<%=link.Order.ToString("0") %>" style="width: 50px; text-align: center;" /></td>
        <td align="center"><%=(link.Activated ? "<img src=\"resources/images/active_l.png\" />" : "<img src=\"resources/images/inactive_l.png\" />")%></td>
        <td align="left">
            <ul class="icon" style="width: 56px;">
                <li><a title="<%=LanguageUtility.GetLanguageText("EDIT", Session)%>" href="<%=baseUrl %>&action=editlink&id=<%=link.ID.ToString("0") %>" class="icon editbn">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("DELETE", Session)%>" href="<%=baseUrl %>&action=dellink&id=<%=link.ID.ToString("0") %>" class="icon deletebn" onclick="javascript: return confirmDelete();">&nbsp</a></li>
            </ul>
        </td>
    </tr>
<%
        }
        if (_List.Count > 0)
        {
%>
    <tr>
        <td colspan="<%=_Group.ImageAvailable ? 4 : 3 %>">&nbsp;</td>
        <td align="center">
            <span id="spSave" class="yui-button yui-link-button yuibtn yuibtn-icon btnapply" style="margin: 5px auto;"><span class="first-child"><input type="submit" value="<%=LanguageUtility.GetLanguageText("CHANGE", Session)%>" /></span></span>
<script type="text/javascript">
function applyOrderChanged() {
    var perID = 'txtOrder_';
    var index = 0;
    var txtOrder = document.getElementById(perID + index.toString());
    var ids = '';
    var orders = '';
    while(txtOrder != null) {
        txtOrder.value = txtOrder.value.trim();
        
        if (!checkInputNumber(txtOrder)) return;
        
        if (parseInt(txtOrder.value, 10) != parseInt(txtOrder.getAttribute('order'))) {
            ids += '|' + txtOrder.getAttribute('linkid');
            orders += '|' + parseInt(txtOrder.value, 10);
        }
        
        index++;
        txtOrder = document.getElementById(perID + index.toString());
    }
    
    if(ids != '') {
        var url = '<%=baseUrl %>';
        url += '&action=order&ids=' + encodeURIComponent(ids) + '&orders=' + encodeURIComponent(orders);
        location.href = url;
    }
}
    YAHOO.util.Event.onContentReady('spSave', function () {
        var oAddCat = new YAHOO.widget.Button("spSave");
        oAddCat.on("click", applyOrderChanged);
    });
</script>
        </td>
        <td colspan="2">&nbsp;</td>
    </tr>
<%
        }
    }
%>
</table>
<script type="text/javascript">
function checkInputNumber(txt) {
    var errorMessage = CheckFieldString("noblank", txt, '<%=LanguageUtility.GetLanguageText("INVALID_NUMBER") %>');
    errorMessage += CheckFieldString("integer", txt, '<%=LanguageUtility.GetLanguageText("INVALID_NUMBER") %>');
    if(errorMessage != "")
    {
        alert(errorMessage);
        txt.select();
        txt.focus();
        return false;
    }
    return true;
}

function confirmDelete() {
    return confirm('<%=LanguageUtility.GetLanguageText("CONFIRM_DELETE", Session).Replace("<br />", "\\n")%>');
}
</script>
<%} %>